package com.example.business;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ProductServiceImpl {


    private final ArrayList<String> booksList;
    private final ArrayList<String> musicList;
    private final ArrayList<String> movieList;

    public ProductServiceImpl() {
        booksList = new ArrayList<String>();
        musicList = new ArrayList<String>();
        movieList = new ArrayList<String>();
        initCategories();
    }

    private void initCategories() {
        booksList.add("1000 lie under the watter");
        booksList.add("White canine");
        booksList.add("Abandoned world");

        musicList.add("Life is too short");
        musicList.add("Shape of my heart");
        musicList.add("The best is yet to come");

        movieList.add("The others");
        movieList.add("Fury");
        movieList.add("Prestige");
    }

    public List<String> getProductCategories() {
        List<String> result = new ArrayList<String>();
        result.add("Books");
        result.add("Music");
        result.add("Movies");
        return result;
    }

    public List<String> getProducts(String category) {
        switch (category.toLowerCase()) {
            case "books":
                return booksList;
            case "music":
                return musicList;
            case "movies":
                return movieList;
        }
        return null;
    }

    public boolean addProduct(String category, String product) {
        switch (category.toLowerCase()) {
            case "books":
                return booksList.add(product);
            case "music":
                return musicList.add(product);
            case "movies":
                return movieList.add(product);
        }
        return false;
    }
}
